package club.xyes.zkh.ecommerce.commons.dto;

import club.xyes.zkh.ecommerce.commons.entity.Shop;
import com.alibaba.fastjson.JSON;
import lombok.Data;

/**
 * Create by 郭文梁 2019/5/7 0007 09:59
 * MinimalShopInfo
 * 最小Shop信息
 *
 * @author 郭文梁
 * @data 2019/5/7 0007
 */
@Data
public class MinimalShopInfo {
    /**
     * 从Shop创建shopInfo
     *
     * @param shop Shop
     * @return ShopInfo
     */
    public static MinimalShopInfo fromShop(Shop shop) {
        MinimalShopInfo shopInfo = new MinimalShopInfo();
        shopInfo.setShopId(shop.getId());
        shopInfo.setOpenId(shop.getWxOpenId());
        return shopInfo;
    }

    /**
     * 商铺ID
     */
    private Integer shopId;
    /**
     * 当前OpenId
     */
    private String openId;

    /**
     * 转换为Json字符串
     *
     * @return 字符串
     */
    public String toJson() {
        return JSON.toJSONString(this);
    }
}
